home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / progut~1 / stdwin.zoo / vtest / dummyserial.c next >
Encoding:
C/C++ Source or Header  |  1989-10-18  |  1015 b   |  82 lines

  1. /* Dummy implementation of serial driver interface.
  2.    This code behaves like a device echoing all input. */
  3.  
  4. #include "tools.h"
  5. #include "stdwin.h"
  6. #include "vt.h"
  7. #include "vtserial.h"
  8.  
  9. bool
  10. openserial()
  11. {
  12.     return TRUE;
  13. }
  14.  
  15. bool
  16. closeserial()
  17. {
  18.     return TRUE;
  19. }
  20.  
  21. static int nchars;
  22. static char *buffer;
  23.  
  24. bool
  25. sendserial(buf, len)
  26.     char *buf;
  27.     int len;
  28. {
  29.     int n= nchars;
  30.     
  31.     if (len < 0)
  32.         len= (int)strlen(buf);
  33.     L_EXTEND(nchars, buffer, char, len);
  34.     if (nchars == n + len) {
  35.         EVENT e;
  36.         memcpy(buffer + n, buf, len);
  37.         e.type= WE_SERIAL_AVAIL;
  38.         wungetevent(&e);
  39.     }
  40. }
  41.  
  42. int
  43. receiveserial(buf, len)
  44.     char *buf;
  45.     int len;
  46. {
  47.     CLIPMAX(len, nchars);
  48.     if (len > 0) {
  49.         memcpy(buf, buffer, len);
  50.         if (len < nchars)
  51.             memcpy(buffer, buffer+len, nchars - len);
  52.         L_SETSIZE(nchars, buffer, char, nchars - len);
  53.     }
  54.     return len;
  55. }
  56.  
  57. bool
  58. breakserial()
  59. {
  60.     return FALSE;
  61. }
  62.  
  63. bool
  64. speedserial()
  65. {
  66.     return FALSE;
  67. }
  68.  
  69. void
  70. receivefile()
  71. {
  72. }
  73.  
  74. bool
  75. vtsend(vt, buf, len)
  76.     VT *vt;
  77.     char *buf;
  78.     int len;
  79. {
  80.     return sendserial(buf, len);
  81. }
  82.